package org.triumphxx.rule;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.triumphxx.rule.dto.AgeRuleDTO;
import org.triumphxx.ruletemplate.AbstractRule;

import static org.triumphxx.constant.RuleConstant.MATCH_AGE;


/**
 * @author:triumphxx
 * @Date: 2024/1/8
 * @Time: 14:27
 * @微信公众号：思考集结处
 * @网站：http://blog.triumphxx.com.cn
 * @GitHub https://github.com/triumphxx
 * @Desc: 年龄规则
 **/
@Data
@Slf4j
public class AgeRule extends AbstractRule  {
    @Override
    public boolean execute(Object ruleDTO) {
        AgeRuleDTO ageRuleDTO = new AgeRuleDTO();
        //对象属性赋值
        BeanUtils.copyProperties(ruleDTO,ageRuleDTO);
        log.info("开始执行关于年龄的校验规则，传入的年龄信息为:{}",ageRuleDTO.getAge());
        if (ageRuleDTO.getAge() > MATCH_AGE) {
            return true;
        }
        return false;
    }

}
